/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmdbResultSetCache_h
/*     */   extends DmdbResultSetCache
/*     */ {
/*  33 */   int offset = 0;
/*     */   
/*  35 */   short nflds = -1;
/*     */   
/*     */ 
/*     */   byte[] rowbuf;
/*     */   
/*  40 */   private DmdbColumn[] cols = null;
/*     */   
/*     */   public DmdbResultSetCache_h(DmdbStatement_bs stmt, DmdbColumn[] colsInfo) {
/*  43 */     super(stmt, colsInfo);
/*  44 */     this.rowbuf = null;
/*  45 */     this.cols = colsInfo;
/*     */   }
/*     */   
/*     */   void env_stmt_init_curbuf() {
/*  49 */     this.rownum = 0;
/*  50 */     this.offset = 0;
/*  51 */     this.curpos = 0;
/*     */   }
/*     */   
/*     */   public void fillBuffer(byte[] buffer, int len, int rows) {
/*  55 */     env_stmt_init_curbuf();
/*     */     
/*  57 */     this.rowbuf = buffer;
/*     */     
/*  59 */     this.rownum = rows;
/*  60 */     this.realLen = len;
/*     */     
/*  62 */     this.nflds = ((short)this.cols.length);
/*     */   }
/*     */   
/*     */   public void fillBuffer2(byte[] buffer, int off, int len, int rows) {
/*  66 */     env_stmt_init_curbuf();
/*     */     
/*  68 */     if (this.rowbuf == null) {
/*  69 */       this.rowbuf = new byte[len];
/*  70 */     } else if (this.rowbuf.length < len) {
/*  71 */       this.rowbuf = new byte[len];
/*     */     }
/*     */     
/*  74 */     System.arraycopy(buffer, off, this.rowbuf, 0, len);
/*     */     
/*  76 */     this.rownum = rows;
/*  77 */     this.realLen = len;
/*     */     
/*  79 */     this.nflds = ((short)this.cols.length);
/*     */   }
/*     */   
/*     */   public void addBuffer(byte[] buffer, int len, int rows) {
/*  83 */     byte[] tmp = new byte[this.realLen + len];
/*  84 */     System.arraycopy(this.rowbuf, 0, tmp, 0, this.realLen);
/*  85 */     System.arraycopy(buffer, 0, tmp, this.realLen, len);
/*     */     
/*  87 */     this.rowbuf = tmp;
/*  88 */     this.rownum += rows;
/*  89 */     this.realLen += len;
/*     */   }
/*     */   
/*     */   public byte[] getBytes(short columnNo) throws SQLException {
/*  93 */     return rec4_get_nth_fld_data(this.rowbuf, this.offset, columnNo);
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean next()
/*     */   {
/*  99 */     if (this.curpos >= this.rownum) {
/* 100 */       return false;
/*     */     }
/*     */     
/* 103 */     int rec_len = rec4_get_len(this.rowbuf, this.offset);
/*     */     
/* 105 */     this.offset += rec_len;
/*     */     
/* 107 */     if (this.offset >= this.realLen) {
/* 108 */       this.curpos += 1;
/* 109 */       return true;
/*     */     }
/*     */     
/* 112 */     this.curpos += 1;
/*     */     
/* 114 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean previous()
/*     */   {
/* 120 */     if (this.curpos <= 0) {
/* 121 */       return false;
/*     */     }
/*     */     
/* 124 */     this.offset = 0;
/* 125 */     for (short i = 0; i < this.curpos - 1; i = (short)(i + 1)) {
/* 126 */       this.offset += rec4_get_len(this.rowbuf, this.offset);
/*     */     }
/*     */     
/* 129 */     this.curpos -= 1;
/*     */     
/* 131 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean absolute(int position)
/*     */   {
/* 137 */     if (position < 0) {
/* 138 */       position = 0;
/*     */     }
/*     */     
/* 141 */     if (position >= this.rownum) {
/* 142 */       position = this.rownum - 1;
/*     */     }
/*     */     
/* 145 */     this.offset = 0;
/* 146 */     for (short i = 0; i < position; i = (short)(i + 1)) {
/* 147 */       this.offset += rec4_get_len(this.rowbuf, this.offset);
/*     */     }
/* 149 */     this.curpos = position;
/*     */     
/* 151 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   short rec4_read_2byte_len(byte[] addr, int off)
/*     */   {
/* 160 */     return (short)(((short)addr[off] << 8) + (short)(0xFF & addr[(off + 1)]));
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   short rec4_get_var_alen(byte[] addr, int off, byte[] nth_ctl_len)
/*     */   {
/* 169 */     if ((addr[off] & 0x80) != 0) {
/* 170 */       nth_ctl_len[0] = 1;
/*     */       
/* 172 */       return (short)(addr[off] & 0x7F);
/*     */     }
/* 174 */     nth_ctl_len[0] = 2;
/*     */     
/* 176 */     return rec4_read_2byte_len(addr, off);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   int rec4_get_nth_fld_offset(byte[] rec, int recOff, short nthFld)
/*     */   {
/* 194 */     int head = recOff + 2 + 8;
/*     */     
/* 196 */     int recLen = Convertion.getShort(rec, recOff);
/*     */     
/* 198 */     if (recLen != 0) {
/* 199 */       return Convertion.getUShort(rec, head + nthFld * 2) + 
/* 200 */         recOff;
/*     */     }
/*     */     
/* 203 */     head += this.nflds * 2;
/* 204 */     int fld_len1 = 0;
/* 205 */     long fld_len2 = 0L;
/* 206 */     int offSetRet = head;
/* 207 */     for (int i = 0; i < nthFld; i++) {
/* 208 */       fld_len1 = Convertion.getUShort(rec, offSetRet);
/* 209 */       offSetRet += 2;
/*     */       
/* 211 */       if (-1 == fld_len1) {
/* 212 */         fld_len2 = Convertion.getUInt(rec, offSetRet);
/* 213 */         offSetRet += 4;
/*     */         
/* 215 */         offSetRet = (int)(offSetRet + fld_len2);
/*     */       } else {
/* 217 */         offSetRet += fld_len1;
/*     */       }
/*     */     }
/* 220 */     return offSetRet;
/*     */   }
/*     */   
/*     */   byte[] rec4_get_nth_fld_data(byte[] rec, int recOff, short nthFld) throws SQLException
/*     */   {
/* 225 */     if (rec == null) {
/* 226 */       return null;
/*     */     }
/* 228 */     int nthFldOff = rec4_get_nth_fld_offset(rec, recOff, nthFld);
/*     */     
/* 230 */     int fld_len1 = Convertion.getUShort(rec, nthFldOff);
/* 231 */     if (65534 == fld_len1) {
/* 232 */       return null;
/*     */     }
/* 234 */     byte[] retBuf = null;
/* 235 */     int dataOff = nthFldOff + 2;
/*     */     
/* 237 */     if (65535 != fld_len1) {
/* 238 */       retBuf = new byte[fld_len1];
/* 239 */       System.arraycopy(rec, dataOff, retBuf, 0, fld_len1);
/* 240 */       return retBuf;
/*     */     }
/*     */     
/* 243 */     int fld_len2 = Convertion.getInt(rec, dataOff);
/* 244 */     if (fld_len2 <= 0) {
/* 245 */       DBError.throwSQLException(20004);
/*     */     }
/* 247 */     dataOff += 4;
/* 248 */     retBuf = new byte[fld_len2];
/* 249 */     System.arraycopy(rec, dataOff, retBuf, 0, fld_len2);
/* 250 */     return retBuf;
/*     */   }
/*     */   
/*     */   int rec4_get_len(byte[] rec, int off)
/*     */   {
/* 255 */     return Convertion.getUShort(rec, off);
/*     */   }
/*     */   
/*     */   long rec_get_rowid() {
/* 259 */     if (this.rowbuf == null) {
/*     */       try
/*     */       {
/* 262 */         DBError.throwSQLException(6021);
/*     */       } catch (SQLException e) {
/* 264 */         e.printStackTrace();
/* 265 */         return 0L;
/*     */       }
/*     */     }
/* 268 */     return Convertion.getLong(this.rowbuf, this.offset + 2);
/*     */   }
/*     */   
/*     */ 
/*     */   public void move_to_next()
/*     */   {
/* 274 */     while (rec4_is_deleted_rec()) {
/* 275 */       int rec_len = rec4_get_len(this.rowbuf, this.offset);
/* 276 */       this.offset += rec_len;
/* 277 */       if (this.offset >= this.realLen) {
/* 278 */         return;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   void rec4_set_deleted_mark() {
/* 284 */     int tmp10_9 = (this.offset + 1); byte[] tmp10_1 = this.rowbuf;tmp10_1[tmp10_9] = ((byte)(tmp10_1[tmp10_9] | 0x80));
/*     */   }
/*     */   
/*     */   boolean rec4_is_deleted_rec() {
/* 288 */     return (this.rowbuf[(this.offset + 1)] & 0x80) != 0;
/*     */   }
/*     */   
/*     */   public Vector getDeletedRowid() {
/* 292 */     Vector tmp = new Vector();
/* 293 */     this.offset = 0;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 298 */     for (int row = 0; row < this.rownum; row++) {
/* 299 */       if (rec4_is_deleted_rec()) {
/* 300 */         long rowid = Convertion.getLong(this.rowbuf, this.offset + 2);
/* 301 */         tmp.add(new Long(rowid));
/*     */       }
/* 303 */       int rec_len = rec4_get_len(this.rowbuf, this.offset);
/* 304 */       this.offset += rec_len;
/*     */     }
/* 306 */     return tmp;
/*     */   }
/*     */   
/*     */   public void setCols(DmdbColumn[] colInfo) {
/* 310 */     this.cols = colInfo;
/*     */   }
/*     */   
/*     */   public final Object clone() {
/* 314 */     DmdbResultSetCache_h rsCache = null;
/* 315 */     rsCache = (DmdbResultSetCache_h)super.clone();
/* 316 */     rsCache.cols = null;
/* 317 */     rsCache.statement = null;
/*     */     
/* 319 */     rsCache.offset = 0;
/* 320 */     rsCache.curpos = 0;
/*     */     
/* 322 */     if (this.rowbuf != null) {
/* 323 */       rsCache.rowbuf = ((byte[])this.rowbuf.clone());
/*     */     }
/* 325 */     return rsCache;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmdbResultSetCache_h.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */